<template>
	<z-paging-swiper ref="paging" class="z-paging" :swiper-style="{ top: '0px' }">
		<template v-slot:top>
			<z-tabs ref="tabs" :current="current" :list="tabList" @change="tabsChange"></z-tabs>
		</template>
		<!-- swiper必须设置height:100%，因为swiper有默认的高度，只有设置高度100%才可以铺满页面  -->
		<swiper class="swiper" :current="current" @animationfinish="animationfinish">
			<swiper-item class="swiper-item" v-for="(item, index) in tabList" :key="index">
				<paginItem :item="item" :swiperCurrent="index" :current="current" :salesmanId="salesmanId" />
			</swiper-item>
		</swiper>
	</z-paging-swiper>
</template>

<script setup>
import http from '@/common/request.js';
import { onLoad, onUnload } from '@dcloudio/uni-app';
import { ref, reactive } from 'vue';
import { getImgSrc, navTo } from '@/common/utils';
import paginItem from './paginItem/paginItem.vue';

const tabList = ref([
	{
		name: '全部',
		value: '',
		params: {}
	},
	{
		name: '待审批',
		value: 1,
		params: {
			approvalState: 1
		}
	},
	{
		name: '已审批',
		value: 2,
		params: {
			approvalState: 2
		}
	},
	{
		name: '抄送我的',
		value: 3,
		params: {
			type: 2
		}
	}
]);

const current = ref(0);

const animationfinish = (d) => {
	current.value = d.detail.current;
};

const tabsChange = (index) => {
	current.value = index;
};

// 已经审批的salesmanId
const salesmanId = ref('');

const setSalesmanId = (id) => {
	salesmanId.value = id;
};

onLoad(() => {
	uni.$on('audited', setSalesmanId);
});

onUnload(() => {
	uni.$off('audited', setSalesmanId);
});
</script>

<style lang="scss" scoped>
.swiper {
	height: 100%;
}
</style>
